<?php

namespace app\data\model;

use think\admin\Model;
use think\admin\model\SystemUser;

/**
 * 商城订单主模型
 * Class ShopOrder
 * @package app\data\model
 */
class ShopOrder extends Model
{
    /**
     * 公证处名称
     * @param string $value
     * @param array  $data
     * @return string
     */
    public static function getNotarialOfficeNameAttr($value,$data)
    {
        $name = NotarialOffice::where('id',$data['notarial_office_id'])->value('name');
        return $name;
    }

    /**
     * 公证员名称
     * @param string $value
     * @param array  $data
     * @return string
     */
    public static function getSysNameAttr($value,$data)
    {
        $name = SystemUser::where('id',$data['system_user_id'])->value('nickname');
        return $name;
    }

    /**
     * 审批人名称
     * @param string $value
     * @param array  $data
     * @return string
     */
    public static function getApprovalNameAttr($value,$data)
    {
        $name = SystemUser::where('id',$data['approval_user_id'])->value('nickname');
        return $name;
    }

    /**
     * 公证事项
     * @param string $value
     * @param array  $data
     * @return string
     */
    public static function getTypeTextAttr($value,$data)
    {
        $type = [0=>'委托书/声明书',1=>'声明书公证',2=>'亲属关系公证'];
        return $type[$data['base_type']];
    }

    /**
     * 公证类型
     * @param string $value
     * @param array  $data
     * @return string
     */
    public static function getMatterNameAttr($value,$data)
    {
        $base_type = $data['base_type'];
        if ($base_type == '0'){
            return '';
        }else{
            $type = [0=>'',1=>'本人办理',2=>'代理人办理'];
            return $type[$data['matter_id']];
        }
        // $name = NotarizedTypeModel::where('id',$data['matter_id'])->value('name');
        // return $name;
    }

    /**
     * 获取订单状态
     * @param string $value
     * @param array  $data
     * @return string
     */
    public static function getStatusTextAttr($value,$data)
    {
        switch ($data['status'])
        {
            case 1:
                $text = "信息确认中";
                break;
            case 2:
                $text = "信息有误";
                break;
            case 3:
                $text = "待认证";
                if ($data['payment_status']==0) $text = '待支付';
                break;
            case 4:
                $text = "认证审核中";
                break;
            case 5:
                $text = "认证通过";
                break;
            case 6:
                $text = "认证失败";
                break;
            case 7:
                $text = "审批人审核";
                break;
            case 8:
                $text = "已完成";
                break;
            default:
                $text = "状态异常";
        }
        return $text;
    }

    /**
     * 其他
     * @param string $value
     * @param array  $data
     * @return array
     */
    public static function getOtherImageAttr($value,$data)
    {
        return explode('|',$data['other']);
    }

    /**
     * 受托人
     * @param string $value
     * @param array  $data
     * @return array
     */
    public static function getTrusteeIdCardImageAttr($value,$data)
    {
        return explode('|',$data['trustee_id_card']);
    }

    /**
     * 购房协议
     * @param string $value
     * @param array  $data
     * @return array
     */
    public static function getClientHousePurchaseAgreementImageAttr($value,$data)
    {
        return explode('|',$data['client_house_purchase_agreement']);
    }

    /**
     * 购房协议
     * @param string $value
     * @param array  $data
     * @return array
     */
    public static function getClientPropertyInformationImageAttr($value,$data)
    {
        return explode('|',$data['client_property_information']);
    }
}